startTestGroup('Base Classes');

window.Blank = window.x = window.success = window.BaseClass = window.baseClassInstances = '';

// A blank class shout have the _prototype and all it's members
Blank = new jClass();
x = new Blank();
assertNotNull('Testing _prototype and _prototype members', x._prototype, x._prototype.typeName, x._prototype.implementing, x._prototype.extending, x._prototype.instanceId);

baseClassInstances = 0;
BaseClass = jClass({
    constructor : function() {
        baseClassInstances++;
    },
    public : {
        pMethod : function() {
            return true;
        },
        retPrivate : function() {
            return privMethod();
        },
        test : function() { return true; },
        pVar : 2,
        getter : Get(function() {
            return 2;
        }),
        setter : Set(function(val) {
            _setter = val;
        }),
        getset : GetSet(function() {
            return _getset;
        }, function(val) {
            _getset = val;
        }),
        stat : Static(true),
        getSetter : function() {
            return _setter;
        },
        testoverride : function() { return this.tooverride(); },
        tooverride : function() { return false; },
        overload : Overload(function() { return 0; }, function(param) { return 1}, function(param, param1) { return 2}, function(param1, param2, param3, param4, param5) { return 5; })
    },
    private : {
        privMethod : function() {
            return privVar == pVar;
        },
        privVar : 2
    },
    static : {
        STATIC : true
    }
});

x = new BaseClass();
assertTrue('BaseClass constructor called',baseClassInstances == 1)
assertNotNull('Testing jClass inheritance on BaseClass', x._prototype, x._prototype.typeName, x._prototype.implementing, x._prototype.extending, x._prototype.instanceId, x.isImplementationOf, x.isInstanceOf);
assertTrue('BaseClass should contain static declared members', BaseClass.STATIC, BaseClass.stat);
assertNull('BaseClass instance should not contain static declared members', x.STATIC, x.stat);
assertTrue('Accessing public member', x.pMethod(), x.pVar == 2);
assertNull('Accessing private member should return undefined', x.privVar, x.privMethod);
assertTrue('Accessing public method that reads from private space', x.retPrivate());
x.setter = 3;
assertNull('Testing WriteOnly properties', (x.getSetter() == 3 ? undefined : '!='), x.setter);
window.success = false;
try { x.getter = 2; } catch(ex) { success = (ex.message == "Property is Read-Only"); }
assertTrue('Testing ReadOnly properties', x.getter == 2, success);
assertTrue('Testing Overloading methods', x.overload() == 0, x.overload(1) == 1, x.overload(1,2) == 2, x.overload(1,2,3,4,5) == 5, x.overload(1,2,3) == 2, x.overload(1,2,3,4,5,6) == 5);

delete(Blank);
delete(x);
delete(success);
